package com.zhledu.string;

import com.zhledu.course.string.GenerateChineseName;
import org.junit.Test;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

public class GeneratePhone {
    private long num = 100 * 100 * 100 ;

    @Test
    public void testhone2File() throws Exception {
        StringBuffer sb = null;
        int n = 0;
        BufferedWriter writer = null;
        for (int i = 0; i <= num; i++) {
            sb = new StringBuffer();
            if (i % 1000 == 0) {
                try {
                    if (writer != null) {
                        writer.close();
                    }
                } catch (Exception e) {

                }
                writer = new BufferedWriter(new FileWriter(new File("/Users/zhli/Desktop/student/phone-" + n + ".txt")));
                n++;
                System.out.println(n * 1000 + "条记录");
            }

            writer.write(GenerateChineseName.getPhone());
            writer.newLine();
        }
        if(writer!=null)
        {
            writer.close();
        }
        System.out.println("记录生成");
    }

}
